<?php
/**
 * Created by PhpStorm.
 * User: kaka
 * Date: 2020/9/20
 * Time: 21:30
 */
namespace container;

class Single{

    public static $instance = null;

    private function __construct(){
        echo 'new-class';
    }

    public static function getInstance ()
    {
        if(!self::$instance){
            self::$instance = new self();
        }
        
        return self::$instance;
    }

    public function getName()
    {
        echo '我是单例模式中的一个方法';
    }
}